import java.lang.reflect.Method;

/**
 * Created by Administrator on 2017/11/1.
 */
public class TestTwo {
    public static void main(String[] args) throws Exception {
        Class c=Class.forName("Person");//通过类名拿到类对象
        Person p= (Person) c.newInstance();//创造实例
        Method[] methods=c.getMethods();
        for(Method m:methods)
        {
            System.out.println(m);
        }
        Method speak=c.getMethod("speak",String.class,int.class);
        speak.invoke(p,"aaa",111);
    }
}
